cmake_minimum_required(VERSION 3.10.0)
project(xlint-test VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 阻止msvc unicode警告，
set(MSVC_AUX_FLAG "/wd4819;/source-charset:utf-8;/execution-charset:utf-8") # 代码文件和编译后的字符串都使用utf-8编码
add_compile_options("$<$<AND:$<C_COMPILER_ID:MSVC>,$<VERSION_GREATER:$<C_COMPILER_VERSION>,18.99>>:${MSVC_AUX_FLAG}>")
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,18.99>>:${MSVC_AUX_FLAG}>")

# 编译信息
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # 以json文件保存编译命令行, 生成的compile_commands.json 在构建目录，仅makefile和ninja构建器可用

# CMAKE_CONFIGURATION_TYPES主要用于复合配置生成器（例如生成Visual Studio工程，默认的构建配置）
set(CMAKE_CONFIGURATION_TYPES Debug Release)

if(MSVC)
    set(libxlnt_root "D:/xlnt/vc15_x64")
elseif(MINGW AND WIN32)
    set(libxlnt_root "D:/xlnt/mingw530_32")
endif()

if(libxlnt_root)
    list(APPEND
        CMAKE_PREFIX_PATH
        "${libxlnt_root}"
    )
endif()

find_package(Xlnt)

add_executable(xlint-test main.cpp)

target_link_libraries(xlint-test PRIVATE xlnt::xlnt)
target_include_directories(xlint-test PRIVATE "./include")